<?php
/**
 * Created by PhpStorm.
 * User: yuguozhen
 * Date: 16/7/22
 * Time: 下午2:03
 */
namespace models\Timer\Count;
class StatisticsModel extends \models\StatisticsDataResultModel{

    /**
     * @param $name 记录名称
     * @param $prev_start 开始时间
     * @param $prev_end 结束时间
     * @param int $type 1：新增值 2.累计值
     * @param string $status 有效标记
     * @return bool 是否记录过
     */
    public function ifRecord($name,$prev_start,$prev_end,$type=1,$status='ENABLE'){
        $count = \models\StatisticsDataResultModel::where('STATISTICS_VARIABLE_NAME','=', $name)
            ->where('STATISTICS_TYPE','=',$type)
            ->where('STATISTICS_DATE','>=',$prev_start)
            ->where('STATISTICS_DATE','<=',$prev_end)
            ->where('VALID_FLAG','=',$status)
            ->count();

        if($count > 0){
            return true;
        }else{
            return false;
        }
    }
}